<template>
  <div class="container-content">
    <el-form
      ref="formRef"
      :model="formObject"
      label-width="90px"
      label-position="left"
    >
      <el-card shadow="never" class="mt20">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="单据类型">
              <el-select
                v-model="formObject.shipperType"
                placeholder="单据类型"
                style="width: 100%"
                @change="selectshipper"
              >
                <el-option
                  label="业务组织"
                  value="BD_OwnerOrg"
                  checked
                ></el-option>
                <el-option label="供应商组织" value="BD_Supplier"></el-option>
                <el-option label="客户组织" value="BD_Customer"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收料部门">
              <el-input v-model="formObject.receiveDept">
              </el-input>
            </el-form-item>
          </el-col>
          <!-- </el-row>
        <el-row :gutter="20"> -->
          <el-col :span="12">
            <el-form-item label="采购部门">
              <el-input
                v-model="formObject.purchaseDept"
                suffix-icon="el-icon-search"
                @focus="openList('采购部门')"
              >
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="采购组">
              <el-date-picker
                v-model="formObject.purchaseGroup"
                type="date"
                placeholder="选择日期"
                style="width: 100%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收料日期">
              <el-date-picker
                v-model="formObject.receiveTime"
                type="date"
                placeholder="选择日期"
                style="width: 100%"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <!-- </el-row>
        <el-row :gutter="20"> -->
          <el-col :span="12">
            <el-form-item label="收料员">
              <el-input
                v-model="formObject.receiveBy"
                suffix-icon="el-icon-search"
                @focus="openList('收料员')"
              >
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="采购员">
              <el-input
                v-model="formObject.purchaseBy"
                suffix-icon="el-icon-search"
                @focus="openList('采购员')"
              >
              </el-input>
            </el-form-item>
          </el-col>
          <!-- </el-row>
        <el-row :gutter="20"> -->
          <el-col :span="12">
            <el-form-item label="供应商">
              <el-input
                v-model="formObject.supplierCode"
                suffix-icon="el-icon-search"
                @focus="openList('仓管员')"
              >
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="验收方式">
              <!-- 数量验收；金额验收；比例验收) -->
              <el-input
                v-model="formObject.checkMethod"
                type="textarea"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货方">
              <el-input
                v-model="formObject.providerId"
                type="textarea"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货联系人">
              <el-input
                v-model="formObject.providerContacts"
                type="textarea"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货方地址">
              <el-input
                v-model="formObject.providerAddress"
                type="textarea"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结算方">
              <el-input
                v-model="formObject.balanceId"
                type="textarea"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款方">
              <el-input
                v-model="formObject.receiveId"
                type="textarea"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮箱">
              <el-input
                v-model="formObject.email"
                type="textarea"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <div class="desc-title">收料通知明细</div>
      <el-table
        :data="formObject.materialLists"
        style="width: 100%"
        highlight-current-row
        border
        :key="flag"
      >
        <template #empty
          ><el-button plain type="primary" round @click="addNewRow"
            >添加新行</el-button
          ></template
        >
        <el-table-column label="操作" width="120px">
          <template slot-scope="scope">
            <el-button
              plain
              icon="el-icon-plus"
              size="small"
              @click="handleDataAdd(scope.$index, scope.row)"
            ></el-button>
            <el-button
              plain
              icon="el-icon-minus"
              size="small"
              @click="handleDataDelete(scope.$index, scope.row)"
            ></el-button>
          </template>
        </el-table-column>
        <el-table-column label="物料编码">
          <template slot-scope="scope">
            <el-input v-model="scope.row.materialCode">
              <i
                slot="suffix"
                class="el-icon-search"
                @click="openList('明细', scope.$index)"
              ></i>
            </el-input>
          </template>
        </el-table-column>
        <el-table-column label="物料名称">
          <template slot-scope="scope">
            <el-form-item label-width="0px" style="margin: 0">
              <el-input disabled v-model="scope.row.materialName"></el-input>
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column label="规格型号">
          <template slot-scope="scope">
            <el-input disabled v-model="scope.row.materialModel"></el-input>
          </template>
        </el-table-column>
        <el-table-column label="单位">
          <template slot-scope="scope">
            <el-input v-model="scope.row.receiveUnit">
              <i
                slot="suffix"
                class="el-icon-search"
                @click="openList('单位', scope.$index)"
              ></i>
            </el-input>
          </template>
        </el-table-column>
        <el-table-column label="交货数量">
          <template slot-scope="scope">
            <el-input v-model="scope.row.deliveryNum"></el-input>
          </template>
        </el-table-column>
        <el-table-column label="预计到货日期">
          <template slot-scope="scope">
            <el-input v-model="scope.row.exceptArrivalTime" disabled></el-input>
          </template>
        </el-table-column>
        <el-table-column label="供应商交货数量">
          <template slot-scope="scope">
            <el-input v-model="scope.row.supplierDeliveryNum" disabled></el-input>
          </template>
        </el-table-column>
        <el-table-column label="计价单位">
          <template slot-scope="scope">
            <el-input v-model="scope.row.pricingUnit">
              <i
                slot="suffix"
                class="el-icon-search"
                @click="openList('仓库', scope.$index)"
              ></i>
            </el-input>
          </template>
        </el-table-column>
        <el-table-column label="计价数量">
          <template slot-scope="scope">
            <el-input disabled v-model="scope.row.pricingNum"></el-input>
          </template>
        </el-table-column>
        <el-table-column label="仓库">
          <template slot-scope="scope">
            <el-input v-model="scope.row.warehouseCode">
              <i
                slot="suffix"
                class="el-icon-search"
                @click="openList('仓库', scope.$index)"
              ></i>
            </el-input>
          </template>
        </el-table-column>
        <el-table-column label="仓位">
          <template slot-scope="scope">
            <el-input disabled v-model="scope.row.warehousePosition"></el-input>
          </template>
        </el-table-column>

        <el-table-column label="库存状态">
          <template slot-scope="scope">
            <el-input v-model="scope.row.inventoryStatus" disabled></el-input>
          </template>
        </el-table-column>
        <el-table-column label="批号">
          <template slot-scope="scope">
            <el-input disabled v-model="scope.row.batchNum"></el-input>
          </template>
        </el-table-column>
        <el-table-column label="拒收数量">
          <template slot-scope="scope">
            <el-input v-model="scope.row.rejectedNum"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="拒收原因">
          <template slot-scope="scope">
            <el-input v-model="scope.row.rejectedReason"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="合同单号">
          <template slot-scope="scope">
            <el-input v-model="scope.row.contractCode"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="税率%">
          <template slot-scope="scope">
            <el-input v-model="scope.row.taxRate"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="单价">
          <template slot-scope="scope">
            <el-input v-model="scope.row.price"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="含税单价">
          <template slot-scope="scope">
            <el-input v-model="scope.row.containsTaxPrice"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="源单类型">
          <template slot-scope="scope">
            <el-input v-model="scope.row.sourceType"> </el-input>
          </template>
        </el-table-column>
        <!-- <el-table-column label="原单编号">
          <template slot-scope="scope">
            <el-input v-model="scope.row.remarks"> </el-input>
          </template>
        </el-table-column> -->
        <!-- <el-table-column label="订单单号">
          <template slot-scope="scope">
            <el-input v-model="scope.row.remarks"> </el-input>
          </template>
        </el-table-column> -->
        <el-table-column label="库存单位">
          <template slot-scope="scope">
            <el-input v-model="scope.row.inventoryUnit"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="库存单位数量">
          <template slot-scope="scope">
            <el-input v-model="scope.row.inventoryUnitNum"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="分录价目表">
          <template slot-scope="scope">
            <el-input v-model="scope.row.entryPriceList"> </el-input>
          </template>
        </el-table-column>
        <!-- <el-table-column label="运行状态">
          <template slot-scope="scope">
            <el-input v-model="scope.row.remarks"> </el-input>
          </template>
        </el-table-column> -->
        <el-table-column label="订单数量">
          <template slot-scope="scope">
            <el-input v-model="scope.row.orderNum"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="不良品折让金额">
          <template slot-scope="scope">
            <el-input v-model="scope.row.defectiveDiscountAmount"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="入库关联不良品折让金额">
          <template slot-scope="scope">
            <el-input v-model="scope.row.inventoryDefectiveDiscountAmount"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="当前对账单号">
          <template slot-scope="scope">
            <el-input v-model="scope.row.currentReconciliationCode"> </el-input>
          </template>
        </el-table-column>
        <el-table-column label="历史对账单号">
          <template slot-scope="scope">
            <el-input v-model="scope.row.historyReconciliationCode"> </el-input>
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog
      width="60%"
      :title="title"
      :visible.sync="dialogTableVisible"
      :append-to-body="appendbody"
    >
      <el-table
        :data="gridData"
         @row-dblclick="getRow"
        v-if="shipper == 'BD_OwnerOrg' && title == '货主'"
      >
        <el-table-column
          property="deptCode"
          label="编码"
          width="150"
        ></el-table-column>
        <el-table-column
          property="deptName"
          label="名称"
          width="200"
        ></el-table-column>
        <el-table-column property="level" label="形态">
          <!-- 层级(0集团公司 1子公司 2部门) -->
          <template slot-scope="scope">
            <p v-if="scope.row.level == 0">集团公司</p>
            <p v-if="scope.row.level == 1">子公司</p>
            <p v-if="scope.row.level == 2">部门</p>
          </template>
        </el-table-column>
        <el-table-column
          property="parentName"
          label="核算组织"
        ></el-table-column>
        <!-- <el-table-column
          property="address"
          label="核算组织类型"
          width="200"
        ></el-table-column> -->
        <el-table-column
          property="businessDept"
          label="业务组织"
        ></el-table-column>
        <el-table-column property="status" label="组织职能"></el-table-column>
        <el-table-column property="isSend" label="数据状态"></el-table-column>
        <el-table-column property="deptDesc" label="描述"></el-table-column>
        <el-table-column property="leader" label="联系人"></el-table-column>
        <el-table-column property="phone" label="联系电话"></el-table-column>
        <!-- <el-table-column property="address" label="地址"></el-table-column> -->
        <el-table-column property="createBy" label="创建人"></el-table-column>
        <el-table-column
          property="createTime"
          label="创建日期"
        ></el-table-column>
        <!-- <el-table-column property="address" label="修改人"></el-table-column>
        <el-table-column property="address" label="修改日期"></el-table-column> -->
        <!-- <el-table-column property="address" label="禁用状态"></el-table-column>
        <el-table-column property="address" label="禁用人"></el-table-column> -->
      </el-table>
      <el-table
        :data="gridData"
         @row-dblclick="getRow"
        v-if="shipper == 'BD_Supplier' && title == '货主'"
      >
        <el-table-column
          property="supplierCode"
          label="编码"
          width="150"
        ></el-table-column>
        <el-table-column
          property="supplierName"
          label="名称"
          width="200"
        ></el-table-column>
        <el-table-column property="forShort" label="简称"></el-table-column>
        <el-table-column
          property="supplierGroup"
          label="供应商分组"
        ></el-table-column>
        <el-table-column
          property="examineId"
          label="审核人"
          width="200"
        ></el-table-column>
        <el-table-column
          property="examineTime"
          label="审核日期"
        ></el-table-column>
        <el-table-column
          property="dataState"
          label="数据状态"
        ></el-table-column>
        <el-table-column
          property="disabledState"
          label="禁用状态"
        ></el-table-column>
      </el-table>
      <el-table
        :data="gridData"
         @row-dblclick="getRow"
        v-if="shipper == 'BD_Customer' && title == '货主'"
      >
        <el-table-column
          property="customerCode"
          label="客户编码"
          width="150"
        ></el-table-column>
        <el-table-column
          property="customerName"
          label="客户名称"
          width="200"
        ></el-table-column>
        <el-table-column property="abbreviation" label="简称"></el-table-column>
        <el-table-column
          property="supplierGroup"
          label="单据状态"
        ></el-table-column>
        <el-table-column
          property="isUsed"
          label="禁用状态"
          width="200"
        ></el-table-column>
        <el-table-column
          property="examineTime"
          label="审核人"
        ></el-table-column>
        <el-table-column
          property="dataState"
          label="审核日期"
        ></el-table-column>
        <el-table-column
          property="customerGroup"
          label="客户分组"
        ></el-table-column>
      </el-table>
      <el-table :data="gridData"  @row-dblclick="getRow" v-if="title == '部门'">
        <el-table-column
          property="deptCode"
          label="编码"
          width="150"
        ></el-table-column>
        <el-table-column
          property="deptId"
          label="助记码"
          width="200"
        ></el-table-column>
        <el-table-column property="deptName" label="名称"></el-table-column>
        <el-table-column
          property="parentName"
          label="上级部门"
        ></el-table-column>
        <el-table-column
          property=""
          label="HR部门"
          width="200"
        ></el-table-column>
        <el-table-column property="" label="来源于s-HR"></el-table-column>
        <el-table-column property="status" label="数据状态"></el-table-column>
        <el-table-column property="" label="禁用状态"></el-table-column>
        <el-table-column property="deptName" label="部门全称"></el-table-column>
      </el-table>
      <el-table :data="gridData"  @row-dblclick="getRow" v-if="title == '库存组'">
        <el-table-column
          property="date"
          label="业务组编码"
          width="150"
        ></el-table-column>
        <el-table-column
          property="shipperCode"
          label="业务组名称"
          width="200"
        ></el-table-column>
        <el-table-column
          property="address"
          label="业务组类型"
        ></el-table-column>
        <el-table-column property="address" label="启用"></el-table-column>
      </el-table>
      <el-table :data="gridData"  @row-dblclick="getRow" v-if="title == '仓管员'">
        <el-table-column property="nickName" label="名称"></el-table-column>
        <el-table-column property="userCode" label="职员编码"></el-table-column>
        <el-table-column property="deptName" label="部门"></el-table-column>
        <el-table-column property="isUsed" label="禁用状态"></el-table-column>
      </el-table>
      <el-table :data="gridData"  @row-dblclick="getRow" v-if="title == '明细'">
        <el-table-column property="materialCode" label="编码"></el-table-column>
        <el-table-column property="materialName" label="名称"></el-table-column>
        <el-table-column property="model" label="规格型号"></el-table-column>
        <!-- <el-table-column property="isChange" label="数据状态"></el-table-column>
        <el-table-column property="isUsed" label="禁用状态"></el-table-column> -->
        <!-- <el-table-column
          property="materialProperty"
          label="物料属性"
        ></el-table-column> -->
        <el-table-column
          property="purchaseUnitName"
          label="基本单位"
        ></el-table-column>
        <!-- <el-table-column property="isUsed" label="已使用"></el-table-column> -->
      </el-table>
      <el-table :data="gridData"  @row-dblclick="getRow" v-if="title == '单位'">
        <el-table-column
          property="meteringUnitCode"
          label="编码"
        ></el-table-column>
        <el-table-column
          property="meteringUnitName"
          label="名称"
        ></el-table-column>
        <el-table-column
          property="isBase"
          label="基准计量单位"
        ></el-table-column>
        <el-table-column property="isUsed" label="数据状态"></el-table-column>
      </el-table>
      <el-table :data="gridData"  @row-dblclick="getRow" v-if="title == '仓库'">
        <el-table-column property="wareCode" label="编码"></el-table-column>
        <el-table-column property="wareName" label="名称"></el-table-column>
        <el-table-column property="address" label="仓库地址"></el-table-column>
        <el-table-column
          property="wareManagement"
          label="仓库负责人"
        ></el-table-column>
        <el-table-column property="address" label="仓库属性"></el-table-column>
        <el-table-column
          property="address"
          label="第三方仓储类型"
        ></el-table-column>
        <el-table-column property="" label="数据状态"></el-table-column>
        <el-table-column property="" label="允许即使库负库存"></el-table-column>
        <el-table-column property="" label="启用仓位管理"></el-table-column>
        <el-table-column property="" label="不参与可发量统计"></el-table-column>
        <el-table-column property="" label="参与预警"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogTableVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogTableVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  addKingReceiveNoticeList,
  getdeptList,
  getMaterial,
  getKingBaseMeteringUnitList,
  getWarehouseList,
  getKingBaseBusinessGroupList,
  getKinguserList,
  getSupplierList,
  getCustomerList,
  getregionList,
} from "@/api/bim/bim";
export default {
  data() {
    return {
      shipper: "",
      appendbody: true,
      title: "",
      num: 0,
      flag: false,
      count: 0,
      gridData: [],
      dialogTableVisible: false,
      formObject: {
        balanceCode: "",
        balanceId: "",
        balanceOrg: "",
        balanceOrgCode: "",
        cargoOwner: "",
        cargoOwnerType: "",
        checkMethod: "",
        confirmName: "",
        confirmState: "",
        confirmTime: "",
        createName: "",
        createTime: "",
        docBusinessType: "",
        docCode: "",
        docStatus: "",
        email: "",
        examineName: "",
        examineTime: "",
        id: "",
        instanceId: "",
        invalidName: "",
        invalidState: "",
        invalidTime: "",
        inventoryGroup: "",
        isSend: 0,
        isUsed: 0,
        lastUpdateName: "",
        lastUpdateTime: "",
        logisticsList: [
          {
            changeTime: "",
            createTime: "",
            endAddress: "",
            id: "",
            isUsed: 0,
            logisticsCompany: "",
            logisticsNum: "",
            logisticsStatus: "",
            receiveNoticeId: "",
            senderPhone: "",
            startAddress: "",
            userId: "",
          },
        ],
        materialLists: [
          {
            amountMoneyBase: "",
            batchNum: "",
            businessPrice: "",
            businessTaxPrice: "",
            changeTime: "",
            checkRate: "",
            containsTaxPrice: "",
            contractCode: "",
            createTime: "",
            currentReconciliationCode: "",
            defectiveDiscountAmount: "",
            deliveryNum: "",
            entryPriceList: "",
            exceptArrivalTime: "",
            exchangeTate: "",
            historyReconciliationCode: "",
            id: "",
            inventoryDefectiveDiscountAmount: "",
            inventoryStatus: "",
            inventoryUnit: "",
            inventoryUnitNum: "",
            isGiveaway: true,
            isReconciliation: "",
            isUsed: 0,
            lineNumber: "",
            lineStatus: "",
            materialCode: "",
            materialDetail: {
              auxiliaryUnit: "",
              batchNum: "",
              bomVer: "",
              businessProcess: "",
              cardNum: "",
              cardRelationNum: "",
              changeTime: "",
              checkNum: "",
              checkRelationNum: "",
              concessionAcceptanceNum: "",
              concessionAcceptanceRelationNum: "",
              confirmAdvice: "",
              confirmArrivalTime: "",
              confirmDeliveryNum: "",
              createTime: "",
              executeBy: "",
              executeTime: "",
              id: "",
              industrialWasteNum: "",
              industrialWasteRelationNum: "",
              isIncomingInspection: "",
              isUrgent: "",
              isUsed: 0,
              lineStatus: "",
              manufactureTime: "",
              materialCode: "",
              materialDetailSerials: [
                {
                  batchNumAuxiliary: "",
                  changeTime: "",
                  checkResult: "",
                  createTime: "",
                  id: "",
                  inventoryRelationNumAuxiliary: "",
                  isUsed: 0,
                  manufactureTimeAuxiliary: "",
                  materialDetailId: "",
                  numAuxiliary: "",
                  receiveNoticeId: "",
                  receiveNoticeMaterialId: "",
                  refundRelationNumAuxiliary: "",
                  serialCode: "",
                  supplierNumAuxiliary: "",
                  useDecision: "",
                  userId: "",
                  validToAuxiliary: "",
                },
              ],
              materialId: "",
              materialModel: "",
              materialName: "",
              materialWasteNum: "",
              materialWasteRelationNum: "",
              orderCode: "",
              planTrackingCode: "",
              qualifiedInventoryNum: "",
              qualifiedNum: "",
              receiveNoticeId: "",
              receiveNoticeMaterialId: "",
              receivedNumAuxiliaryUnit: "",
              refundRelationNum: "",
              rejectNum: "",
              remark: "",
              requireBy: "",
              requireDept: "",
              requireTrackingCode: "",
              sampleDestructionNum: "",
              serialCodeUnit: "",
              serialCodeUnitNum: "",
              serialCodeUpload: "",
              shelfLifeCycle: "",
              sourceDocCode: "",
              sourceDocType: "",
              supplierBatchNum: "",
              totalInventoryNum: "",
              totalRefundNum: "",
              unqualifiedRelationNum: "",
              userId: "",
              validTo: "",
              warrantyTime: "",
              warrantyUnit: "",
            },
            materialId: "",
            materialModel: "",
            materialName: "",
            moneyAmount: "",
            orderNum: "",
            price: "",
            pricingNum: "",
            pricingUnit: "",
            receiveNoticeId: "",
            receiveUnit: "",
            rejectedNum: "",
            rejectedReason: "",
            relationCode: "",
            relationId: "",
            sourceMaterialDetailId: "",
            sourceType: "",
            supplierDeliveryNum: "",
            taxAmount: "",
            taxAmountBase: "",
            taxRate: "",
            totalTaxPrice: "",
            totalTaxPriceBase: "",
            userId: "",
            warehouseCode: "",
            warehouseId: "",
            warehousePosition: "",
          },
        ],
        providerAddress: "",
        providerCode: "",
        providerContacts: "",
        providerId: "",
        purchaseBy: "",
        purchaseDept: "",
        purchaseDeptCode: "",
        purchaseGroup: "",
        purchaseOrg: "",
        purchaseOrgCode: "",
        receiveBy: "",
        receiveCode: "",
        receiveDept: "",
        receiveDeptCode: "",
        receiveId: "",
        receiveOrg: "",
        receiveOrgCode: "",
        receiveTime: "",
        requireDept: "",
        requireDeptCode: "",
        settlementCurrency: "",
        settlementMethod: "",
        state: "",
        supplierCode: "",
        supplierId: "",
        termOfPayment: "",
        userId: "",
        wholeDiscountAmount: "",
      },
    };
  },

  methods: {
    selectshipper(val) {
      this.shipper = val;
    },
    // 获取每次点击的内容进行区分，并在此方法内进行打开弹窗及数据的请求
    openList(item, i) {
      this.count = i;
      this.dialogTableVisible = true;
      this.title = item;
     
    },
    // 获取点击的表格内容并且关闭弹窗且进行内容的回显
    getRow(row) {
      this.dialogTableVisible = false;
      // if (this.title == "货主") {
      //   if (this.shipper == "BD_OwnerOrg") {
      //     this.formObject.kingProfitLossEntity.shipperCode = row.businessCode;
      //     this.formObject.kingProfitLossEntity.shipperName = row.businessName;
      //     // 供应商组织
      //   } else if (this.shipper == "BD_Supplier") {
      //     this.formObject.kingProfitLossEntity.shipperCode = row.supplierCode;
      //     this.formObject.kingProfitLossEntity.shipperName = row.supplierName;
      //     // 客户组织
      //   } else if (this.shipper == "BD_Customer") {
      //     this.formObject.kingProfitLossEntity.shipperCode = row.customerCode;
      //     this.formObject.kingProfitLossEntity.shipperName = row.customerName;
      //   }
      // } else if (this.title == "部门") {
      //   this.formObject.kingProfitLossEntity.deptId = row.bizDeptCode;
      //   this.formObject.kingProfitLossEntity.deptName = row.deptName;
      // } else if (this.title == "库存组") {
      //   this.formObject.kingProfitLossEntity.inventoryOrgCode =
      //     row.inventoryOrgCode;
      // } else if (this.title == "仓管员") {
      //   this.formObject.kingProfitLossEntity.keeperUserCode = row.userId;
      //   this.formObject.kingProfitLossEntity.keeperUserName = row.nickName;
      // } else if (this.title == "单位") {
      //   this.formObject.kingProfitLossDetailEntities[
      //     this.count
      //   ].purchaseUnitName = row.meteringUnitName;
      //   this.formObject.kingProfitLossDetailEntities[this.count].childUnitCode =
      //     row.meteringUnitCode;
      //   // this.flag=Math.random()*1000000000000
      //   this.flag = 2;
      // } else if (this.title == "仓库") {
      //   this.formObject.kingProfitLossDetailEntities[this.count].warehouseCode =
      //     row.wareCode;
      //   this.flag = 3;
      //   getregionList({
      //     warehouseId: row.id,
      //   }).then((src) => {
      //     if (src.code == 200) {
      //       this.formObject.kingProfitLossDetailEntities[
      //         this.count
      //       ].regionName = src.rows[0].regionName;
      //       this.formObject.kingProfitLossDetailEntities[
      //         this.count
      //       ].warehouseId = src.rows[0].warehouseId;
      //       this.flag = 4;
      //     }
      //   });
      // } else if (this.title == "明细") {
      //   this.formObject.kingProfitLossDetailEntities[this.count] = row;
      //   this.flag = 1;
      // }
    },
    selectProject() {},
    handleDataAdd() {
      if (this.formObject.kingProfitLossDetailEntities == undefined) {
        this.formObject.kingProfitLossDetailEntities = [];
      }
      let obj = {
        checkNum: "",
        createBy: "",
        createTime: "",
        id: "",
        inventoryNum: "",

        materialCode: "",
        pageNo: 0,
        pageSize: 0,
        params: {},
        profitLossNum: "",
        relationId: "",
        remark: "",
        remarks: "",
        searchValue: "",
        shipperId: "",
        unit: "",
        updateBy: "",
        updateTime: "",
        warehouseCode: "",
      };
      this.formObject.kingProfitLossDetailEntities.push(obj);
    },
    handleDataDelete(index, row) {
      this.$confirm("请确认是否要删除此行？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.formObject.kingProfitLossDetailEntities.splice(index, 1);
          this.num = this.num - 1;
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    addNewRow() {
      this.num = this.num + 1;
      this.handleDataAdd();
    },
    onSubmit() {
      this.formObject.kingProfitLossEntity.id = new Date();
      addKingReceiveNoticeList(this.formObject).then((res) => {
        if (res.code === 200) {
          this.$message({
            message: "新增成功！",
            type: "success",
          });
        }
      });
    },
  },
  created() {},
};
</script>

<style lang="scss" scoped>
.divider {
  margin: 0;
}
.el-icon-search {
  margin-top: 70% !important;
}
</style>
